﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;
using System.Net;

namespace Common.Notifications
{
    public class Notification
    {
        public static void SendEmail(List<String> emails, String subject, String body)
        {
            MailMessage msg = new MailMessage();

            foreach (var item in emails)
            {
                msg.To.Add(new MailAddress(item));
            }
            msg.Subject = subject;
            msg.Body = body;

            msg.IsBodyHtml = false;

            using (SmtpClient clienteSmtp = new SmtpClient())
            {
                //Enable SSL
                clienteSmtp.EnableSsl = true;
                clienteSmtp.Timeout = 30;

                clienteSmtp.Send(msg);
            }
        }

        public static void SendSMS(List<string> numeroscel, string subject, string body)
        {
            MailMessage msg = new MailMessage();

            foreach (var item in numeroscel)
            {
                var normalizado = item.TrimStart('0');
                msg.To.Add(new MailAddress(normalizado + "@sms.movistar.net.ar"));
                msg.To.Add(new MailAddress(normalizado + "@personal-net.com.ar"));
                msg.To.Add(new MailAddress(normalizado + "@sms.ctimovil.com.ar"));
                msg.To.Add(new MailAddress(normalizado + "@sms.cmail.com.ar"));
            }
            msg.Subject = subject;
            msg.Body = body;

            msg.IsBodyHtml = false;

            SmtpClient clienteSmtp = new SmtpClient();
            //Enable SSL
            clienteSmtp.EnableSsl = true;
            clienteSmtp.Timeout = 30;

            clienteSmtp.Send(msg);
        }
    }
}
